package com.dba.example.gwt.client;

import com.dba.example.gwt.client.gin.ExampleGinjector;
import com.google.gwt.activity.shared.ActivityManager;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.place.shared.PlaceController;
import com.google.gwt.place.shared.PlaceHistoryHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;

public class Main implements EntryPoint {

	interface DefaultUiBinder extends UiBinder<Widget, Main> {
	}

	private static DefaultUiBinder uiBinder = GWT.create(DefaultUiBinder.class);

	private ExampleGinjector injector = GWT.create(ExampleGinjector.class);
	
	@SuppressWarnings("unused")
	private PlaceController pc = injector.getPlaceController();

	@UiField
	SimplePanel container;
	
	@UiField
	Label welcome;
	
	public void onModuleLoad() {
		RootLayoutPanel rp = RootLayoutPanel.get();
		rp.add(uiBinder.createAndBindUi(this));
		container.setHeight((Window.getClientHeight() - 20) + "px");
		container.setWidth((Window.getClientWidth() - 20) + "px");

		ActivityManager activityManager = injector.getActivityManager();
		activityManager.setDisplay(container);

		PlaceHistoryHandler historyHandler = injector.getPlaceHistoryHandler();
		historyHandler.handleCurrentHistory();
	}

}
